<?php
/**
 * 
 * @author guibinyu
 * @date 2017-06-15 04:14:50
 */
class Oauth   
{
    
   private $params;
   private $Wechat;
   public function __construct($Wechat)
    {
        $this->Wechat = $Wechat;
    }
    public function getRedirect()
    {
        $callback = "http://www.51kuangquanshui.com";
        $state = "xx=xx";
        $result = $this->Wechat->Oauth->getRedirect($callback,$state);
        return $result;
    }
     public function getAccessToken()
    {
        $code = "061X07ir0BNt8c1iIhjr0wn8ir0X07iv";
        $result = $this->Wechat->Oauth->getAccessToken($code);
        return $result;
    }
       public function getRefreshToken()
    {
        $refresh_token = "teEBX3BfeGjaDTXIUUo_yzy5CHolB-h7LbXmcQN0ynyZNjROFGptuT0UTLv6RZgVI_41AlMADHurjhgEizeCau9bp3cXS6c_-n70znP4vsw";
        $result = $this->Wechat->Oauth->getRefreshToken($refresh_token);
        return $result;
    }
    public function getUserInfo()
    {
        $params = array(
               'access_token' =>'oYVyYw2BzLX8eJ1I-oCDSN6z4avI',
                'openid' =>'oYVyYw2BzLX8eJ1I-oCDSN6z4avI'
        );
        $access_token = $params['access_token'];
        $openid = $params['openid'];
        
        $result = $this->Wechat->Oauth->getUserInfo($access_token, $openid);
        return $result;
    }
    public function __call($name, $arguments)
    {
        exit("Test does not have [{$name}] method !");
    }
     
//index, view, create, update, delete, options
}